using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using Shpm.App.Search.Bean;
using Shpm.App.Search.Dao;

public partial class App_Search_MonitorDetail : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!Page.IsPostBack)
        {
            //lbl.Text = Request.QueryString["LBLTEXT"].ToString();
            //DropDownList1.SelectedValue = Request.QueryString["LBLTEXT"].ToString();

            this.ViewState["GROUP_ID"] = Request.QueryString["GROUP_ID"];
            initAll();
            DrpGroup.SelectedValue = Request.QueryString["GROUP_ID"].ToString();
            lbl.Text = DrpGroup.SelectedItem.Text;
        }
    }

    protected override void OnPreRender(EventArgs e)
    {
        MonitorDetailBean dataBean = new MonitorDetailBean();
        MonitorDetailDao Dao = new MonitorDetailDao();
        dataBean.GroupId = Convert.ToInt32(this.ViewState["GROUP_ID"]);
        IList dataList = Dao.ListMonitorDetail(dataBean);
        hidId.Value = "";
        hidChannel.Value = "";
        if (dataList.Count > 0)
        {
            for (int i = 0; i < dataList.Count; i++)
            {
                MonitorDetailBean bean = new MonitorDetailBean();
                bean = (MonitorDetailBean)dataList[i];
                if (hidId.Value != "")
                {
                    hidId.Value = hidId.Value + "," + bean.IpAddress;
                    hidChannel.Value = hidChannel.Value + "," + bean.Channel;
                }
                else
                {
                    hidId.Value = bean.IpAddress;
                    hidChannel.Value = Convert.ToString(bean.Channel);
                }
            }
        }
    }

    private void initAll()
    {
        MonitorDetailDao Dao = new MonitorDetailDao();
        MonitorDetailBean paramBean = new MonitorDetailBean();
        IList list = null;
        list = Dao.ListMonitorGroup(paramBean);

        DrpGroup.DataSource = list;
        DrpGroup.DataBind();
    }
    protected void DrpGroup_SelectedIndexChanged(object sender, EventArgs e)
    {
        lbl.Text = DrpGroup.SelectedItem.Text;
        this.ViewState["GROUP_ID"] = DrpGroup.SelectedValue;
    }
}
